package com.vdongchina.miniapp.http.dto;

import com.vdongchina.miniapp.commons.MiniAppException;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * Copyright (C)
 * FileName: AppResp
 * Author:   maokai
 * Date:     2021/8/12 14:23
 * Description: 相应结果
 */
@Data
public class AppResp implements Serializable {
    static Long successCode = 0L;
    private Long error;
    private Long errcode;
    private String errmsg;
    private String message;
    public void success() throws MiniAppException {
        if (Objects.nonNull(this.error) && !successCode.equals(error)) {
            String format = String.format("接口请求异常：【 %d : %s】", errcode, errmsg);
            throw new MiniAppException(format);
        }
    }
}
